package com.zr.java8.pattern.factory;

import com.zr.java8.pattern.factory.impl.BmwCar;
import com.zr.java8.pattern.factory.impl.TeslaCar;

public class CarFactory {
    public static Car createCar(String type){
        Car car;
        switch(type) {
            case "bmw":
                car = new BmwCar();
                break;
            case "tesla":
                car = new TeslaCar();
                break;
            default:
                car = null;
                break;
        }

        return car;
    }
}
